'use strict';

/* Controllers */
app.controller('loansStr', function($scope,$compile,ngDialog,uiLoad,$state,user,rest,$ocLazyLoad,tipService ) {
   var data = angular.copy($scope.ngDialogData, {});
   $scope.rentType = {};
   $scope.rentTypeList = [{
        name: '纯手续费模式',
        value: 0
    }, {
        name: '手续费+等额本息模式',
        value: 1
    }];
   $scope.showMes = 1;
   console.log(data);
   $scope.successfulStr1 = function(){
      if (!$scope.rentType.selected) {
        tipService.show("body", {
            message: "未选择还款模式",
            notice: "danger"
        }, 3);
      }
      $scope.repaymentPattern = $scope.rentType.selected.value;
      rest.post({
          methodId: '5032',         
           data: {
            'landlordId': user.get('landlordId'),
            'creditAmount': $scope.applyLoanNum,
            'repaymentPattern': $scope.repaymentPattern
         },
          success: function(res) {
             if (res.code == 0) {
              $scope.showMes = 0;
              $scope.$apply();
             }else{
              $scope.showMes = 1;
              res.res.msg = res.res.msg.replace("接口","")
              tipService.show("body", {
                  message: res.res.msg,
                  notice: "danger"
              }, 3);
             }
          },
          error: function() {
             $scope.showMes = 1;
          }
      })
   }
});
